-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(nx-dev): improve auto-scrolling so it does not interfere with users reading the content #19196
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
5b17197
to
617716f
Compare
617716f
to
d04d5c4
Compare
112011b
to
dda0931
Compare
ce69771
to
8f1a1c6
Compare
8f1a1c6
to
3fb7633
Compare
…ers reading the content
3fb7633
to
8134daf
Compare
if (messages.length > currentMessagesLength.current) { | ||
currentMessagesLength.current = messages.length; | ||
shouldScroll = true; | ||
} else if (el.scrollTop + el.clientHeight + 50 >= el.scrollHeight) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 50?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's exactly the scrollHeight
then it's hard for user to scroll to the bottom fast enough and re-enable auto-scroll. The 50 pixels (about two lines of text) seem to work well enough on both desktop and mobile.
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
This PR improves auto-scrolling, so we check if the user is close to the bottom of the content before scrolling them down. It prevents problems where users can lose the position of where they are reading.
Drastically improves the mobile experience as well where the screen no longer jumps around all the time when typing or reading.
Before:
before.mp4
After:
after.mp4